package com.kc.web.controller.business;

import com.kc.business.domain.BizTourguideGoods;
import com.kc.business.service.IBizTourguideGoodsService;
import com.kc.common.annotation.Log;
import com.kc.common.annotation.RepeatSubmit;
import com.kc.common.core.controller.BaseController;
import com.kc.common.core.domain.AjaxResult;
import com.kc.common.core.page.TableDataInfo;
import com.kc.common.enums.BusinessType;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

/**
 * 导游套餐controller
 */
@RestController
@RequestMapping("/business/tourguideGoods")
public class BizTourguideGoodsController extends BaseController {
    @Autowired
    private IBizTourguideGoodsService tourguideGoodsService;
    /**
     * 套餐列表
     * @param tourguideGoods
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguideGoods:list')")
    @GetMapping("/list")
    public TableDataInfo getList(BizTourguideGoods tourguideGoods){
        startPage();
        return getDataTable(tourguideGoodsService.getList(tourguideGoods));
    }
    /**
     * 套餐新增
     * @param bizTourguideGoods
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguideGoods:add')")
    @Log(title = "导游套餐管理", businessType = BusinessType.INSERT)
    @PostMapping
    @RepeatSubmit
    public AjaxResult add(@Validated @RequestBody BizTourguideGoods bizTourguideGoods) {
        return toAjax(tourguideGoodsService.add(bizTourguideGoods));
    }
    /**
     * 套餐修改
     * @param bizTourguideGoods
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguideGoods:edit')")
    @Log(title = "导游套餐管理", businessType = BusinessType.UPDATE)
    @PutMapping
    @RepeatSubmit
    public AjaxResult edit(@Validated @RequestBody BizTourguideGoods bizTourguideGoods) {
        return toAjax(tourguideGoodsService.edit(bizTourguideGoods));
    }
    /**
     * 商品删除
     * @param id
     * @return
     */
    @PreAuthorize("@ss.hasPermi('business:tourguideGoods:remove')")
    @Log(title = "导游套餐管理", businessType = BusinessType.DELETE)
    @DeleteMapping("/{id}")
    public AjaxResult remove(@PathVariable Integer id) {
        BizTourguideGoods tourguideGoods = new BizTourguideGoods();
        tourguideGoods.setId(id);
        //bizBusinessGoods = businessGoodsService.getListInfo(bizBusinessGoods);
        tourguideGoods.setIsDeleted(1);
        return toAjax(tourguideGoodsService.remove(tourguideGoods));
    }
}
